import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;

public class Main {
   public static void main(String[] args) throws IOException {
      new Thread(() -> {
         try {
            new TCPLoopServer().start();
         } catch (IOException e) {
            e.printStackTrace();
         }
      }).start();

      try (Socket socket = new Socket("127.0.0.1", 8888)) {
         OutputStream os = socket.getOutputStream();
         DataOutputStream dos = new DataOutputStream(os);
         for (int i = 1; i <= 4; i++) {
            if (i == 4) {
               dos.writeUTF("exit");
            } else {
               dos.writeUTF("第" + i + "次：Hello");
            }
         }
         dos.close();
      }
   }
}